package com.freight.user.serviceimpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freight.core.common.utils.SecurityUtil;
import com.freight.user.dto.CompanyDto;
import com.freight.user.mapper.CompanyVoMapper;
import com.freight.user.service.ICompanyVoService;
import com.freight.user.vo.AppointCompanyInfoVo;
import com.freight.user.vo.CompanyDetailInfoVo;
import com.freight.user.vo.CompanyInfoVo;
import com.freight.user.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * 订单预约接口实现
 *
 * @author huyingtai
 */
@Slf4j
@Service
@Transactional
public class ICompanyVoServiceImpl extends ServiceImpl<CompanyVoMapper, UserVo> implements ICompanyVoService {

    @Autowired
    private CompanyVoMapper companyVoMapper;

    @Autowired
    SecurityUtil securityUtil;

    @Override
    public CompanyInfoVo getCompanyInfoVoByUserId(Long userId) {
        return companyVoMapper.getCompanyInfoVoByUserId(userId);
    }

    @Override
    public List<CompanyInfoVo> getCompanyInfoVoByUserIds(Long[] userId) {
        return companyVoMapper.getCompanyInfoVoByUserIds(userId);
    }

    @Override
    public List<CompanyInfoVo> getRegistCompanyInfoVo(Long[] userIds) {
        return companyVoMapper.getRegistCompanyInfoVo(userIds);
    }


    @Override
    public AppointCompanyInfoVo getAppointCompanyInfoVoByUserId(Long userId) {
        return companyVoMapper.getAppointCompanyInfoVoByUserId(userId);
    }

    @Override
    public List<AppointCompanyInfoVo> getAppointCompanyInfoVoByUserIds(Long[] userIds) {
        return companyVoMapper.getAppointCompanyInfoVoByUserIds(userIds);
    }

    @Override
    public HashMap<Long, AppointCompanyInfoVo> getAppointCompanyInfoMapVoByUserIds(Long[] userIds) {
        List<AppointCompanyInfoVo> res = getAppointCompanyInfoVoByUserIds(userIds);
        HashMap<Long,AppointCompanyInfoVo> map = new HashMap<>();
        for(AppointCompanyInfoVo re:res){
            map.put(re.userId,re);
        }
        return map;
    }

    @Override
    public Page<CompanyDetailInfoVo> getCompanyInfoVo(Page page, CompanyDto companyDto) {
        return companyVoMapper.getCompanyInfoVo(page,companyDto);
    }

    @Override
    public List<CompanyDetailInfoVo> getCompanyInfoVo(CompanyDto companyDto) {
        return companyVoMapper.getCompanyInfoVo(companyDto);
    }

    @Override
    public List<CompanyInfoVo> getCompanyBaseInfoVo(CompanyDto companyDto) {
        return companyVoMapper.getCompanyBaseInfoVo(companyDto);
    }


}
